﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace TK.Mqtt.Client.Demo
{
    class Program
    {
        public static void Main(string[] args)
        {
            CreateHostBuilder(args).Build().Run();
        }

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
            .ConfigureAppConfiguration((host, config) =>
            {
                config.AddJsonFile("mqttconfig.json", true, true);
            })
            .ConfigureLogging(log =>
            {
                log.ClearProviders();
                log.SetMinimumLevel(LogLevel.Trace).AddConsole().AddDebug();
            })
            .ConfigureServices((host, services) =>
            {
                //services.AddSingleton<IDataHandler, MyReceiveHandler>();
                services.AddMqttClientWrapper(host.Configuration).
                AddMqttDataHandler<MyReceiveHandler>();
            });
    }
}
